/*
               File: ModNroTlf
        Description: Modificar Numero Telefono
             Author: GeneXus C# Generator version 8_0_0-201
       Generated on: 21 de Setiembre de 2010 17:41:25.70
       Program type: Callable routine
          Main DBMS: sqlserver
*/
namespace GeneXus.Programs {
   using System;
   using System.Collections;
   using GeneXus.Utils;
   using GeneXus.Resources;
   using GeneXus.Application;
   using GeneXus.Metadata;
   using com.genexus;
   using com.genexus.ui;
   using com.genexus.uifactory;
   using GeneXus.Windows;
   using System.Data;
   using System.Data.SqlClient;
   using GeneXus.Data;
   using GeneXus.Data.FAT;
   using GeneXus.Http;
   using GeneXus.Procedure;
   using System.Threading;
   using GeneXus.XML;
   using GeneXus.Encryption;
   using GeneXus.Http.Client;
   public class pmodnrotlf_wrapper : GXJWin
   {
      public pmodnrotlf_wrapper( int hnd ,
                                 ModelContext jContext ) : base(hnd, jContext)
      {
      }

   }

   public class pmodnrotlf : GXWinProcedure
   {
      public pmodnrotlf( int hnd ,
                         ModelContext jContext ) : base(hnd, jContext)
      {
         IsMain = true;
         context = new GxContext();
         context.DataStores.Add(new GxDataStore( new GxSqlServer(),"Default"));
         dsDefault = context.GetDataStore("Default") ;
      }

      public pmodnrotlf( )
      {
         context = new GxContext();
         context.DataStores.Add(new GxDataStore( new GxSqlServer(),"Default"));
         dsDefault = context.GetDataStore("Default") ;
         IsMain = true;
      }

      public pmodnrotlf( IGxContext context ) : base(-1, null)
      {
         this.context = context;
         IsMain = false;
         dsDefault = context.GetDataStore("Default") ;
      }

      public pmodnrotlf( IGxContext context ,
                         int hnd ,
                         ModelContext jContext ) : base(hnd, jContext)
      {
         this.context = context;
         IsMain = false;
         dsDefault = context.GetDataStore("Default") ;
      }

      public void execute( String aP0_Prscod ,
                           long aP1_Cod ,
                           int aP2_Prspretlf ,
                           String aP3_Prsnrotlf ,
                           int aP4_Prsanxtlf ,
                           short aP5_Prsflgmov )
      {
         this.AV9Prscod = aP0_Prscod;
         this.AV8Cod = aP1_Cod;
         this.AV10Prspre = aP2_Prspretlf;
         this.AV11Prsnro = aP3_Prsnrotlf;
         this.AV12Prsanx = aP4_Prsanxtlf;
         this.AV13Prsflg = aP5_Prsflgmov;
         initialize();
         executePrivate();
      }

      public void executeSubmit( String aP0_Prscod ,
                                 long aP1_Cod ,
                                 int aP2_Prspretlf ,
                                 String aP3_Prsnrotlf ,
                                 int aP4_Prsanxtlf ,
                                 short aP5_Prsflgmov )
      {
         pmodnrotlf objpmodnrotlf;
         objpmodnrotlf = new pmodnrotlf();
         objpmodnrotlf.AV9Prscod = aP0_Prscod;
         objpmodnrotlf.AV8Cod = aP1_Cod;
         objpmodnrotlf.AV10Prspre = aP2_Prspretlf;
         objpmodnrotlf.AV11Prsnro = aP3_Prsnrotlf;
         objpmodnrotlf.AV12Prsanx = aP4_Prsanxtlf;
         objpmodnrotlf.AV13Prsflg = aP5_Prsflgmov;
         objpmodnrotlf.initialize();
         Thread execThread;
         execThread = new Thread(new ThreadStart( objpmodnrotlf.executePrivate ));
         execThread.Start();
      }

      void executePrivate( )
      {
         /* GeneXus formulas */
         /* Output device settings */
         cmP00082 = new GxDbCommand(dsDefault.Db, "SELECT [PrsCod], [PrsTlfCod], [PrsPreTlf], [PrsNroTlf], [PrsAnxTlf], [PrsFlgMov] FROM [MMPRS20] (UPDLOCK) WHERE [PrsCod] = ? AND [PrsTlfCod] = ? ", 1, dsDefault,"ModNroTlf","P00082" );
         cmP00082.DbCommand.FetchSize = 1;
         cmP00082.DbCommand.BindString(0,10);
         cmP00082.DbCommand.BindShort(1);
         cmP00082.DbCommand.BindLong(2);
         cmP00082.DbCommand.BindString(3,20);
         cmP00082.DbCommand.BindLong(4);
         cmP00082.DbCommand.BindShort(5);
         cmP00082.AddParameter(1,3,10,0,ParameterDirection.Input);   // GX_SQL_CHAR  GX_CS_STRING
         cmP00082.AddParameter(2,4,10,0,ParameterDirection.Input);   // GX_SQL_NUMERIC  GX_CS_DOUBLE
         cmP00082.SetParameter(0,AV9Prscod);
         cmP00082.SetParameter(1,AV8Cod);
         cmP00082.ErrorMask = GxErrorMask.Lock;
         cmP00082.FetchData( out P00082);
         while ( cmP00082.HasMoreRows )
         {
            A35PrsCod = dsDefault.Db.GetString(cmP00082, P00082, 0) ;
            A220PrsTlf = dsDefault.Db.GetShort(cmP00082, P00082, 1) ;
            A91PrsPreT = dsDefault.Db.GetInt(cmP00082, P00082, 2) ;
            A92PrsNroT = dsDefault.Db.GetString(cmP00082, P00082, 3) ;
            A93PrsAnxT = dsDefault.Db.GetInt(cmP00082, P00082, 4) ;
            A221PrsFlg = dsDefault.Db.GetShort(cmP00082, P00082, 5) ;
            A91PrsPreT = AV10Prspre ;
            A92PrsNroT = AV11Prsnro ;
            A93PrsAnxT = AV12Prsanx ;
            A221PrsFlg = AV13Prsflg ;
            cmP00083 = new GxDbCommand(dsDefault.Db, "UPDATE [MMPRS20] SET [PrsPreTlf]=?, [PrsNroTlf]=?, [PrsAnxTlf]=?, [PrsFlgMov]=?  WHERE [PrsCod] = ? AND [PrsTlfCod] = ?", 1, dsDefault,"ModNroTlf","P00083" );
            cmP00083.AddParameter(2,1,5,0,ParameterDirection.Input);   // GX_SQL_NUMERIC  GX_CS_LONG
            cmP00083.AddParameter(1,3,20,0,ParameterDirection.Input);   // GX_SQL_CHAR  GX_CS_STRING
            cmP00083.AddParameter(2,1,5,0,ParameterDirection.Input);   // GX_SQL_NUMERIC  GX_CS_LONG
            cmP00083.AddParameter(2,2,1,0,ParameterDirection.Input);   // GX_SQL_NUMERIC  GX_CS_SHORT
            cmP00083.AddParameter(1,3,10,0,ParameterDirection.Input);   // GX_SQL_CHAR  GX_CS_STRING
            cmP00083.AddParameter(2,2,2,0,ParameterDirection.Input);   // GX_SQL_NUMERIC  GX_CS_SHORT
            /* Using cursor P00083 */
            cmP00083.SetParameter(0,A91PrsPreT);
            cmP00083.SetParameter(1,A92PrsNroT);
            cmP00083.SetParameter(2,A93PrsAnxT);
            cmP00083.SetParameter(3,A221PrsFlg);
            cmP00083.SetParameter(4,A35PrsCod);
            cmP00083.SetParameter(5,A220PrsTlf);
            cmP00083.ExecuteStmt();
            if ( ( cmP00083 != null ) )
            {
               cmP00083.DbCommand.Close();
            }
            dsDefault.Release() ;
            /* Check if program is canceled. */
            /* Exiting from a For First loop. */
            if (true) break;
         }
         if ( ( cmP00082 != null ) )
         {
            cmP00082.DbCommand.Close();
         }
         dsDefault.Release() ;
         this.cleanup();
      }

      public override int getOutputType( )
      {
         return GxReportUtils.OUTPUT_RVIEWER_DLL ;
      }

      protected void cleanup( )
      {
         dsDefault.Commit();
         if ( IsMain )
         {
            context.CloseConnections() ;
         }
      }

      public override void initialize( )
      {
         A35PrsCod = "" ;
         A220PrsTlf = 0 ;
         A91PrsPreT = 0 ;
         A92PrsNroT = "" ;
         A93PrsAnxT = 0 ;
         A221PrsFlg = 0 ;
         /* GeneXus formulas. */
         Gx_err = 0 ;
      }

      private short AV13Prsflg ;
      private short A220PrsTlf ;
      private short A221PrsFlg ;
      private short Gx_err ;
      private int AV10Prspre ;
      private int AV12Prsanx ;
      private int A91PrsPreT ;
      private int A93PrsAnxT ;
      private long AV8Cod ;
      private String AV9Prscod ;
      private String AV11Prsnro ;
      private String A35PrsCod ;
      private String A92PrsNroT ;
      private IGxDataStore dsDefault ;
      private GxDbCommand cmP00082 ;
      private IDataReader P00082 ;
      private GxDbCommand cmP00083 ;
   }

}
